import http from '@/utils/http'
import type { ParamsData, RoleOptionResponse, UserAddRoleParams, UserAddSaveParams, UserDepResult, UserEditSaveParams, UserResponse, UserResponseData, UserResultResponse } from '../types/user'

enum API {
    USERLIST_URL = '/api/acl/user/list',
    USERSTATUS_URL = '/api/acl/user/status',
    USEREDIT_URL = '/api/acl/user/edit',
    USERDELETE_URL = '/api/acl/user/delete',
    USERADD_URL = '/register',
    USEROPTION_URL = '/api/acl/role/rolelist',
    USERSETROLE_URL='/api/acl/user/action',
    USEDEPOPTION_URL='/api/etp/branch/select'
}

// 用户列表
export const reqUserList = (data: ParamsData) => http.get<any, UserResponseData>(API.USERLIST_URL, { params: data })

// 修改用户状态
export const reqUserStatus = (id: string, status: boolean) => http.patch<any, UserResultResponse>(API.USERSTATUS_URL, { id, status })

// 修改用户信息
export const reqUserEdit = (data: UserEditSaveParams) => http.post<any, UserResultResponse>(API.USEREDIT_URL, data)

// 删除用户
export const reqUserDelete = (id: string) => http.delete<any, UserResultResponse>(API.USERDELETE_URL, { params: { id: id } })

// 新增用户
export const reqUserAdd = (data: UserAddSaveParams) => http.post<any, UserResponse>(API.USERADD_URL, data)

// 角色列表信息
export const reqUserOptions = () => http.get<any,RoleOptionResponse>(API.USEROPTION_URL)

// 部门列表信息
export const reqDepOptions =()=>http.get<any,UserDepResult>(API.USEDEPOPTION_URL)

// 分配用户角色
export const reqUserSetRole =(data:UserAddRoleParams)=>http.post<any,UserResponse>(API.USERSETROLE_URL,data)